<template>
  <div>
    <div class="list">
      <div class="list-item" v-for="item in list" :key="item.id">
        <div class="left">
          <input type="radio" :checked="item.isDone" @click="changeHandler(item.id)"/>
          <div class="text" :class="{ done: item.isDone }">{{ item.name }}</div>
        </div>
        <div class="right">
          <a href="#" @click.prevent="remove(item.id)">删除</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      required: true,
      type: Array,
      default: () => [],
    },
  },
  methods:{
    changeHandler(id){
      this.$emit('change',id)
    },
remove(id){
  this.$emit('remove',id)
}
  }
};
</script>

<style lang='less' scoped>
.list {
  box-shadow: 0 0 5px #cfcfcc;
  .list-item {
    height: 50px;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    border-bottom: #cfcfcc;
    &:last-child {
      border: none;
    }
    .left {
      display: flex;
      align-items: center;
      font-size: 20px;
      .text {
        margin-left: 10px;
      }
    }
    .right {
      display: flex;
      align-items: center;
    }
  }
}
.done {
  color: gray;
  text-decoration: line-through;
}
</style>